Feature: Testing login page of demo.relenta.com

  #    Scenario: Log in / log out without SSL connection
  #    Given navigate to the page "http://demo.relenta.com/"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    When "text_field" component with "id"="username" avaliable
  #    Then type "demo" value in text field with "id"="username"
  #    When "text_field" component with "id"="password" avaliable
  #    Then type "demo" value in text field with "id"="password"
  #    When "button" component with "id"="password" avaliable
  #    Then click button with "value"="Login"
  #    When no message appears in text_field with "id"="error-message"
  #    Then wait till page load
  #    When on the page exists following text:"Email marketing"
  #    Then logoff clicking on link with "xpath"="/html/body/div/div/div/div/a[3]"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    #
  #    Scenario: Log in / log out with SSL connection
  #    Given navigate to the page "https://demo.relenta.com/"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    When "text_field" component with "id"="username" avaliable
  #    Then type "demo" value in text field with "id"="username"
  #    When "text_field" component with "id"="password" avaliable
  #    Then type "demo" value in text field with "id"="password"
  #    When "button" component with "id"="password" avaliable
  #    Then click button with "value"="Login"
  #    When no message appears in text_field with "id"="error-message"
  #    Then wait till page load
  #    When on the page exists following text:"Email marketing"
  #    Then logoff clicking on link with "xpath"="/html/body/div/div/div/div/a[3]"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    #
  #    Scenario: Log in with wrong password
  #    Given navigate to the page "http://demo.relenta.com/"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    When "text_field" component with "id"="username" avaliable
  #    Then type "demo" value in text field with "id"="username"
  #    When "text_field" component with "id"="password" avaliable
  #    Then type "wrong_password" value in text field with "id"="password"
  #    When "button" component with "id"="password" avaliable
  #    Then click button with "value"="Login"
  #    When message in text_field with "id"="error-message" should be equal to "Username and password do not match"
  #    #
  #    Scenario: Log in with wrong username
  #    Given navigate to the page "http://demo.relenta.com/"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    When "text_field" component with "id"="username" avaliable
  #    Then type "wrong_username" value in text field with "id"="username"
  #    When "text_field" component with "id"="password" avaliable
  #    Then type "demo" value in text field with "id"="password"
  #    When "button" component with "id"="password" avaliable
  #    Then click button with "value"="Login"
  #    When message in text_field with "id"="error-message" should be equal to "Username and password do not match"
  #
  #
  #    Scenario: Prepare new filter for Inbox folder and cancel at the very end
  #    Given navigate to the page "http://demo.relenta.com/"
  #    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
  #    When "text_field" component with "id"="username" avaliable
  #    Then type "demo" value in text field with "id"="username"
  #    When "text_field" component with "id"="password" avaliable
  #    Then type "demo" value in text field with "id"="password"
  #    When "button" component with "id"="password" avaliable
  #    Then click button with "value"="Login"
  #    When no message appears in text_field with "id"="error-message"
  #    When on the page exists following button "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[2]/div[3]/div[1]/a[4]"
  #    Then click button with "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[2]/div[3]/div[1]/a[4]"
  #    When on the page exists following button "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[2]/div[4]/div[3]/div/a"
  #    Then click button with "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[2]/div[4]/div[3]/div/a"
  #    When on the page exists following button "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[3]/a"
  #    Then click button with "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[3]/a"
  #    When "text_field" component with "id"="name" avaliable
  #    Then type "demo_filter" value in text field with "id"="name"
  #    And select "No" value in 'Is sender email associated with contact?' list component with "name"="is_assigned"
  #    And select "Inbox" value in 'Apply to messages in folder:' list component with "name"="in_folder"
  #    Then type "demo" value in text field with "id"="filter"
  #    And select "Body" value in 'Look for filter string match in: ' list component with "name"="email_part[]"
  #    #    add action "Mark as Read" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Mark as Read" value in 'Actions:' list component with "id"="action[1]"
  #    #    add action "Move to folder" and subvalue "Inbox" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Move to folder" value in 'Actions:' list component with "id"="action[2]"
  #    And select "Inbox" value in 'Actions:' list component with "id"="folder_id[2]"
  #    #    add action "Delete to Trash" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Delete to Trash" value in 'Actions:' list component with "id"="action[3]"
  #    #    add action "Permanently erase" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Permanently erase" value in 'Actions:' list component with "id"="action[4]"
  #    #    add action "Send an autoresponder" and subvalue "Welcome to This is it!" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Send an autoresponder" value in 'Actions:' list component with "id"="action[5]"
  #    And select "Welcome to This is it!" value in 'Actions:' list component with "id"="autoresponder_id[5]"
  #    #    add action "Assign contact to group" and subvalue "Phone inquiry" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Assign contact to group" value in 'Actions:' list component with "id"="action[6]"
  #    And select "Phone inquiry" value in 'Actions:' list component with "id"="cn_group_id[6]"
  #    #    add action "Create contact from email" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Create contact from email" value in 'Actions:' list component with "id"="action[7]"
  #    #    add action "Archive message" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Archive message" value in 'Actions:' list component with "id"="action[8]"
  #    #    cancelling any changes done to filter by clicking "Cancel" button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/a[2]"
  #    #
  #    Scenario: Create new filter
  #    When on the page exists following button "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[3]/a"
  #    Then click button with "xpath"="html/body/div[1]/div[4]/div[2]/div/div/div[3]/a"
  #    When "text_field" component with "id"="name" avaliable
  #    Then type "demo_filter" value in text field with "id"="name"
  #    And select "No" value in 'Is sender email associated with contact?' list component with "name"="is_assigned"
  #    And select "Inbox" value in 'Apply to messages in folder:' list component with "name"="in_folder"
  #    Then type "demo" value in text field with "id"="filter"
  #    And select "Body" value in 'Look for filter string match in: ' list component with "name"="email_part[]"
  #    #    add action "Mark as Read" by clicking on "add an action..." button
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/div[2]/table/tbody/tr[@id='action_tr']/td[2]/a"
  #    And select "Mark as Read" value in 'Actions:' list component with "id"="action[1]"
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/a[1]"
  #    #
  #    Scenario: Edit filter with name "demo_filter"
  #    When on the page exists following link "text"="demo_filter" click it
  #    And select "Archive message" value in 'Actions:' list component with "id"="action[1]"
  #    Then click button with "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='content']/div[@id='content_wrapper']/div[@id='content_loadable']/form[@id='rule_form']/a[1]"
  #    When on the page exists following link "text"="demo_filter" click it
  #    And verify if value in 'Actions:' list component with "id"="action[1]" = "Archive message"
  #    #
  #    Scenario: Verify if filter present in "Apply filter" droplist
  #    When on the page exists following link "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='sidebar']/div[@id='sidebar_content']/div[@id='sidebar_wrapper']/div[@id='sidebar_folder_tab_content']/ul/li[@id='fld_list70213']/a/span[1]" click it
  #    When on the page exists following link "text"="Filter" click it
  #    And select "demo_filter" value in 'Apply filter:' list component with "id"="filter_id"
  #    #
  #    Scenario: Apply filter present in "Apply filter" droplist for the inbox
  #    When on the page exists following link "xpath"="/html/body/div[@id='page-bg']/div[@id='page']/div[@id='sidebar']/div[@id='sidebar_content']/div[@id='sidebar_wrapper']/div[@id='sidebar_folder_tab_content']/ul/li[@id='fld_list70213']/a/span[1]" click it
  #    When on the page exists following link "text"="Filter" click it
  #    And select "demo_filter" value in 'Apply filter:' list component with "id"="filter_id"
  #    When on the page exists following button "name"="apply" click and press "OK" on pop up
  #    #
  #    Scenario: Delete filter with name "demo_filter"
  #    When on the page exists following link "text"="Manage filters" click it
  #    When on the page exists following link "text"="demo_filter" click it
  #    When on the page exists following link "text"="Delete" click and press "OK" on pop up

  Scenario: Reading emails
    Given navigate to the page "http://demo.relenta.com/"
    When on the page exists following text:"© 2010 Relenta Inc. All rights reserved."
    When "text_field" component with "id"="username" avaliable
    Then type "demo" value in text field with "id"="username"
    When "text_field" component with "id"="password" avaliable
    Then type "demo" value in text field with "id"="password"
    When "button" component with "id"="password" avaliable
    Then click button with "value"="Login"
    When no message appears in text_field with "id"="error-message"
    Then open each email and add tag "test"
        And verify tag "test" was added to each email
        And delete tag "test" in each email